use serde::Deserialize;

#[derive(Debug, Deserialize, Clone, Default)]
pub struct LibImport {
    pub lib_name: String,
    pub element_name: String,
    pub is_default: bool,
    pub command: Option<Vec<String>>, // 用于在配置文件中指定哪些命令行需要执行导入
}

impl LibImport {
    pub fn to_code(&self) -> String {
        if self.is_default {
            format!("import {} from '{}';\n", self.element_name, self.lib_name)
        } else {
            format!(
                "import {{{}}} from '{}';\n",
                self.element_name, self.lib_name
            )
        }
    }
}
